<template>
  <div class="container" :class="{'container-a':isChecked}" @click="isChecked=!isChecked">
    <div class="circle" 
    :class="{
      'a':isChecked,
      'b':!isChecked
    }"
    ></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isChecked: false,
    }
  },
}
</script>

<style scoped>
.container {
  display: inline-block;
  position: relative;
  width: 50px;
  height: 20px;
  border: 1px solid #eee;
  border-radius: 16px;
  background-color: #eee;
  transition: all 0.2s;
  cursor: pointer;
}
.container-a{
  display: inline-block;
  position: relative;
  width: 50px;
  height: 20px;
  border: 1px solid #eee;
  border-radius: 16px;
  background-color: rgb(0, 255, 98);
  transition: all 0.2s;
  cursor: pointer;
}
/* ⚪ */
.circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 30px;
  height: 30px;
  border-radius: 15px;
  background-color: #ffffff;
  box-shadow: 0 1px 3px #909399;
}
.a{
  left: 40px;
  animation: aa 1s infinite;
  animation-iteration-count: 1;
}
.b{
  left: 0px;
  animation: bb 1s infinite;
  animation-iteration-count: 1;
}
@keyframes aa{
  0%{
    left: 0px;
  }
  50%{
    left: 50%;
  }
  100%{
    right: 0px;
  }
}
@keyframes bb{
  0%{
    right: 100%;
  }
  50%{
    right: 50%;
  }
  100%{
    left: 0%;
  }
}
</style>
